/*

	BoundingObjects.h
	
	Definitions of various bounding objects all derived
	from the IBoundingObject interface. These can be used
	for simple collision detection in 3D space.
	
	Written by Sigurd Suhm 2009

*/

#ifndef _BOUNDINGOBJECTS_H
#define _BOUNDINGOBJECTS_H

// Includes
#include "Vector.h"			// Vector classes

namespace EraAstral
{
	namespace core
	{
		// Enum describing the various types of bounding objects
		enum BoundingObjectType
		{
			// 3D bounding sphere
			BO_SPHERE3D,
			// 3D axis aligned box
			BO_AABOX3D
		};
	
		// Bounding object base interface
		class IBoundingObject
		{
			protected:
				// Bounding object type
				BoundingObjectType 	m_type;		
		
			public:			
				// Check if the object intersects another object
				virtual bool Intersects(IBoundingObject *object) = 0;
				
				// Gets the type of the bounding object
				BoundingObjectType	GetType() const { return m_type; }
		};
		
		// Simple 3D bounding sphere
		class BoundingSphere3D : public IBoundingObject
		{
			private:
				// Sphere center position
				Vector3		m_center;
				// Sphere radius
				float		m_radius;
			
			public:
				// Default constructor
				BoundingSphere3D();
				// Constructor setting parameters
				BoundingSphere3D(const Vector3& center, float radius);
				
				// Check if the object intersects another object
				bool Intersects(IBoundingObject *object);
				
				// Accessors
				Vector3		GetCenter() const;
				float		GetRadius() const;
		};
		
		// Axis aligned 3D bounding box
		class BoundingBoxAA3D : public IBoundingObject
		{
			private:
				// Box center position
				Vector3		m_position;
				// Box width, height and depth
				float		m_width, m_height, m_depth;
				
			public:
				// Defatul constructor
				BoundingBoxAA3D();
				// Constructor setting parameters
				BoundingBoxAA3D(const Vector3& position, float width, float height, float depth);
				
				// Check if the object intersects another object
				bool Intersects(IBoundingObject *object);
				
				// Accessors
				Vector3		GetPosition() const;
				float		GetWidth() const;
				float		GetHeight() const;
				float		GetDepth() const;
		};
	}
}

#endif		// _BOUNDINGOBJECTS_H